"""
教学案例：基本语法综合训练
"""


class Calculator:
    def __init__(self):
        self._last = 0
        
    @property
    def last(self):
        return self._last
    
    def add(self, *args):
        self._last = sum(args)
        return self._last
    
    def subtract(self, *args):
        self._last = args[0]
        if len(args) > 1:
            for k in args[1:]:
                self._last -= k
        return self._last
    
    def multiply(self, *args):
        self._last = args[0]
        if len(args) > 1:
            for k in args[1:]:
                self._last *= k
        return self._last
    
    def divide(self, *args):
        self._last = args[0]
        if len(args) > 1:
            for k in args[1:]:
                self._last /= k
        return self._last

cal = Calculator()
cal.add(1, 2.5, 4)
cal.subtract(cal.last, 2, 1)
cal.divide(cal.last, 2, 1)
print(cal.last)